package cn.ike.service.system.impl;

import cn.ike.dao.system.SysLogDao;
import cn.ike.domain.system.SysLog;
import cn.ike.service.system.SysLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class SysLogServiceImpl implements SysLogService {

    // 注入SysLogDao
    @Autowired
    private SysLogDao sysLogDao;

    /**
     * 分页
     * @param companyId
     * @param pageNum
     * @param pageSize
     */
    @Override
    public PageInfo<SysLog> findByPage(String companyId, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<SysLog> sysLogList = sysLogDao.findAll(companyId);
        return new PageInfo<>(sysLogList);
    }

    @Override
    public void save(SysLog log) {
        log.setId(UUID.randomUUID().toString());
        sysLogDao.save(log);
    }
}
